package com.proxy.autoclick.queue;

import java.util.concurrent.BlockingQueue;
import java.io.PrintStream;

public class Consumer extends Thread {
	private BlockingQueue<String> blockingQueue;
	private String consumerName;
	private PrintStream printStream;

	public Consumer(String consumerName, BlockingQueue<String> blockingQueue,
			PrintStream printStream) {
		this.consumerName = consumerName;
		this.blockingQueue = blockingQueue;
		this.printStream = printStream;
	}

	public void run() {
		while (true) {
			try {
				String message = blockingQueue.take();
				printStream.println(this.consumerName + message);
			} catch (InterruptedException ie) {
				ie.printStackTrace();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
